package com.dzt.androidframework.express;

import android.content.Context;

import com.dzt.androidframework.R;
import com.dzt.androidframework.express.javabean.OrderInfoDetailBean;
import com.dzt.androidframework.express.javabean.OrderSite;
import com.dzt.androidframework.recycler.RecyclerAdapter;
import com.dzt.androidframework.recycler.RecyclerHolder;
import com.dzt.androidframework.utils.AppResourceKit;

import java.util.List;

/**
 * Created by M02323 on 2017/9/19.
 * 订单详情适配器
 */

public class OrderDetailAdapter extends RecyclerAdapter<OrderInfoDetailBean> {

	private String state;

	public OrderDetailAdapter(Context context, List<OrderInfoDetailBean> datas, int layoutId, String state) {
		super(context, datas, layoutId);
		this.state = state;
	}

	@Override
	public void convert(RecyclerHolder holder, OrderInfoDetailBean data, int position) {
		if (holder.getItemViewType() == OrderSite.BEGIN) {
			holder.setTextColor(R.id.tv_item_order_detail_time, AppResourceKit.getInstance().getColor(R.color.red));
			holder.setTextColor(R.id.tv_item_order_detail_content, AppResourceKit.getInstance().getColor(R.color.red));
			holder.setMarkerDrawable(R.id.tlmv_item_order_detail, AppResourceKit.getInstance().getDrawable(R.drawable.timeline_bg_red));
		}
		holder.setText(R.id.tv_item_order_detail_content, data.getContext());
		//分两行显示
		holder.setText(R.id.tv_item_order_detail_time,
				data.getTime().toString().substring(0, 10) + "\n" +
						data.getTime().toString().substring(10));
	}

	@Override
	public int getItemViewType(int position) {
		if (position == 0 && state.equals("3")) {
			return OrderSite.BEGIN;
		} else if (position == getItemCount() - 1) {
			return OrderSite.END;
		}
		return super.getItemViewType(position);
	}
}
